home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / EVERYCAT.ICN < prev    next >
Text File  |  1992-09-28  |  1KB  |  52 lines

  1. ############################################################################
  2. #
  3. #    File:     everycat.icn
  4. #
  5. #    Subject:  Procedure for generating all concatenations
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     April 25, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #   everycat(x1, x2, ...) generates the concatenation of every string
  14. #   from !x1, !x2, ... .
  15. #
  16. #   For example, if
  17. #
  18. #    first := ["Mary", "Joe", "Sandra"]
  19. #    last := ["Smith", "Roberts"]
  20. #
  21. #   then
  22. #
  23. #    every write(everycat(first, " ", last))
  24. #
  25. #   writes
  26. #
  27. #    Mary Smith
  28. #    Mary Roberts
  29. #    Joe Smith
  30. #    Joe Roberts
  31. #    Sandra Smith
  32. #    Sandra Roberts
  33. #
  34. #  Note that x1, x2, ... can be any values for which !x1, !x2, ... produce
  35. #  strings or values convertible to strings.  In particular, in the example
  36. #  above, the second argument is a one-character string " ", so that !" "
  37. #  generates a single blank.
  38. #
  39. ############################################################################
  40.  
  41. procedure everycat(args[])
  42.    local arg
  43.  
  44.    arg := get(args) | fail
  45.  
  46.    if *args = 0 then
  47.       suspend !arg
  48.    else
  49.       suspend !arg || everycat ! args
  50.  
  51. end
  52.